////////////////////////////////////////////////////////////
/* CoinNPC Script Original written by Scarface//Odin     //
 *                                                      //
 * This script can be easily edited to be              //
 * used for your server. Throughout the script        //
 * are comments on what each thing does so that      //
 * you can edit this. You can create custom         //
 * teleporting locations and menus.                //
 *                                                //
 * Originally written for use with Moon++        //
 */                                             //
/////////////////////////////////////////////////


#include "StdAfx.h"
#include "Setup.h"

#define COIN_NPC 55560


class SCRIPT_DECL CoinNPC : public GossipScript
{
public:
void GossipHello(Object * pObject, Player* Plr, bool AutoSend);
void GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code);
void GossipEnd(Object * pObject, Player* Plr);
void Destroy()
{
delete this;
}
};
void CoinNPC::GossipHello(Object * pObject, Player* Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
Menu->AddItem(0, "1 Coins Rewards", 1);
Menu->AddItem(0, "2 Coins Rewards", 2);
Menu->AddItem(0, "3 Coins Rewards", 3);
Menu->AddItem(0, "5 Coins Rewards", 4);
Menu->AddItem(0, "10 Coins Rewards", 5);

if(AutoSend)
Menu->SendTo(Plr);
}
bool TradeForCoins(uint32 ItemId, uint8 reqAmt, Player* Plr)
{
if(Plr->GetItemInterface()->GetItemCount(31205, false)>=reqAmt) {
//remove coins
Plr->GetItemInterface()->RemoveItemAmt(31205, reqAmt);
//add item
Item * pItem = objmgr.CreateItem(ItemId, Plr);
Plr->GetItemInterface()->AddItemToFreeSlot(pItem);
return true;
}else
{
//dont have enough coins for this
return false;
}
}
void CoinNPC::GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
Creature * pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?((Creature*)pObject):NULL;
if(pCreature==NULL)
return;

GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pCreature, Plr, true);
break;

case 1: //Menu for 1 Coins
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(5, "Moon++ Token Shard - 1 Coin", 10);           //you can define here a custom item from your DB
Menu->AddItem(5, "Bloodfang Set (Tier 2) - 1 Coin", 11);
Menu->AddItem(5, "Elementium Reinforced Bulwark - 1 Coin", 12);
Menu->AddItem(5, "Lionheart Blade - 1 Coin", 13);
Menu->AddItem(5, "King's Defender - 1 Coin", 14);
Menu->AddItem(0, "[Back]", 99);
Menu->SendTo(Plr);
break;

case 2://Menu for 2 coins
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(5, "Moon++ Token - 2 Coins", 20);                //you can define here a custom item from your DB
Menu->AddItem(5, "Fishing Chair - 2 Coins", 21);
Menu->AddItem(5, "Swift Magic Broom - 2 Coins", 22);
Menu->AddItem(5, "Turbo-Charged Flying Machine Control - 2 Coins", 23);
Menu->AddItem(0, "[Back]", 99);
Menu->SendTo(Plr);
break;

case 3://Menu for 3 coins
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(5, "Rare Moon++ Token - 3 Coins",30);           //you can define here a custom item from your DB
Menu->AddItem(5, "Amani War Bear - 3 Coins", 31);
Menu->AddItem(0, "[Back]", 99);
Menu->SendTo(Plr);
break;

case 4://Menu for 5 coins
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(5, "Epic Moon++ Token - 5 Coins", 40);          //you can define here a custom item from your DB
Menu->AddItem(5, "Phoenix Mount - 5 Coins", 41);
Menu->AddItem(0, "[Back]", 99);
Menu->SendTo(Plr);
break;

case 5://Menu for 10 coins
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(5, "Legendary Moon++ Token - 10 Coins", 50);           //you can define here a custom item from your DB
Menu->AddItem(5, "Server Item - 10 Coins", 53);                      //you can define here a custom item from your DB. rename the "Server Item" to the name of your custom item      
Menu->AddItem(5, "Server Item - 10 Coins", 51);                      //you can define here a custom item from your DB. rename the "Server Item" to the name of your custom item
Menu->AddItem(5, "Server Item - 10 Coins", 52);                      //you can define here a custom item from your DB. rename the "Server Item" to the name of your custom item
Menu->AddItem(0, "[Back]", 99);
Menu->SendTo(Plr);
break;


/*


case 10: { // Moon++ Token Shard id xxxxx
if (TradeForCoins(xxxxx, 1, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 1);
Menu->SendTo(Plr);
break;


case 20:{ // Moon++ Token id xxxxx
if (TradeForCoins(xxxxx, 2, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 2);
Menu->SendTo(Plr);
break;


case 40://Epic Moon++ Token id xxxxx
{
if (TradeForCoins(xxxxx, 5, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 4);
Menu->SendTo(Plr);
break;


case 30://Rare Moon++ Token id xxxxx
{
if (TradeForCoins(xxxxx, 3, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 3);
Menu->SendTo(Plr);
break;

case 51://Server Item id xxxxx
{
if (TradeForCoins(xxxxx, 1, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 5);
Menu->SendTo(Plr);
break;

case 52://Server Item id xxxxx
{
if (TradeForCoins(xxxxx, 1, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 5);
Menu->SendTo(Plr);
break;

*/

case 22://Swift Magic Broom 33184
{
if (TradeForCoins(33184, 2, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 2);
Menu->SendTo(Plr);
break;

case 23://Turbo-charged Flying Machine Control 34061
{
if (TradeForCoins(34061, 2, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 2);
Menu->SendTo(Plr);
break;

case 12://Elementium Reinforced Bulwark 19349
{
if (TradeForCoins(19349, 1, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 1);
Menu->SendTo(Plr);
break;

case 11:{//Bloodfang Set
if(Plr->GetItemInterface()->GetItemCount(31205, false)>=1) {
//remove coins
Plr->GetItemInterface()->RemoveItemAmt(31205, 1);
//give items
TradeForCoins(16832, 1, Plr);
TradeForCoins(16905, 0, Plr);
TradeForCoins(16906, 0, Plr);
TradeForCoins(16907, 0, Plr);
TradeForCoins(16908, 0, Plr);
TradeForCoins(16909, 0, Plr);
TradeForCoins(16910, 0, Plr);
TradeForCoins(16911, 0, Plr);
}else
{
//dont have enough coins for this
Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );
}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 1);
Menu->SendTo(Plr);
break;
case 21://Fishing Chair 33223
{
if (TradeForCoins(33223, 2, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 2);
Menu->SendTo(Plr);
break;

case 13://Lionheart Blade 28428
{
if (TradeForCoins(28428, 1, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 1);
Menu->SendTo(Plr);
break;

case 41://Phoenix 32458
{
if (TradeForCoins(32458, 5, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 4);
Menu->SendTo(Plr);
break;

/*

case 50://Legendary Moon++ Token id xxxxx
{
if (TradeForCoins(xxxxx, 10, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 5);
Menu->SendTo(Plr);
break;

*/

case 31://Amani Warbear 33809
{
if (TradeForCoins(33809, 3, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 3);
Menu->SendTo(Plr);
break;

case 14://King's Defender 28749
{
if (TradeForCoins(28749, 1, Plr))
{Plr->BroadcastMessage("Have fun with your prise." );}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 1);
Menu->SendTo(Plr);
break;

/*

case 53:{//Server Item id xxxxx
if (TradeForCoins(xxxxx, 1, Plr))
{Plr->BroadcastMessage("Have fun with your prise.");}
else{Plr->BroadcastMessage("You have an insufficient amount of coins to support this transaction." );}
}
objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
Menu->AddItem(0, "[Back]", 1);
Menu->SendTo(Plr);
break;

*/

case 99: //main menu
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
Menu->AddItem(0, "1 Coin Rewards", 1);
Menu->AddItem(0, "2 Coins Rewards", 2);
Menu->AddItem(0, "3 Coins Rewards", 3);
Menu->AddItem(0, "5 Coins Rewards", 4);
Menu->AddItem(0, "10 Coins Rewards", 5);
Menu->SendTo(Plr);
break;

}
}
}

void CoinNPC::GossipEnd(Object * pObject, Player* Plr)
{
GossipScript::GossipEnd(pObject, Plr);}

void SetupCoin(ScriptMgr * mgr)
{
GossipScript * gs = (GossipScript*) new CoinNPC();

mgr->register_gossip_script(55560, gs);
}
